﻿@using OperaHouse.Web.Areas.Admin.Models;
@model NewsItemModel
@{
    //page title
    ViewBag.Title = "Tin tức";
}
<script src="@Url.Content("~/Scripts/tinymce/tiny_mce.js")" type="text/javascript"></script>
@using (Html.BeginForm("Edit", "News", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="section-header">
        <div class="title">
            <img src="@Url.Content("~/Content/admin/images/ico-news.png")" alt="" />
            Tin tức @Html.ActionLink("(back to list)", "List")
        </div>
        <div class="options">
            <input type="submit" name="save" class="t-button" value="Save" />
            <span id="newsitem-delete" class="t-button" onclick="confirmDelete()">Delete</span>
        </div>
    </div>
    @Html.Partial("_CreateOrUpdate", Model)
}
<script type="text/javascript">
    function confirmDelete() {
        if (confirm("Are you sure you want to delete?")) {
            var id = $("#Id").val();
            jQuery.ajax({
                type: "POST",
                url: "/Admin/News/Delete",
                data: { "id": id },
                success: function (data) {
                    if (data.result == "ok") {
                        window.location = "/Admin/News/List";
                    }
                    else {
                        alert("Can not delete!");
                    }

                }
            });
        }
    }
</script>